<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset="utf-8">
<title>模拟器配置列表</title>
<@fm.header />
<style type="text/css">
body {
	font: 12px/20px "微软雅黑", "宋体", Arial, sans-serif, Verdana, Tahoma;
	padding: 0;
	margin: 0;
}
.layout-split-proxy-h{
	position:absolute;
	width:2px;
	background:#888;
	font-size:1px;
	cursor:e-resize;
	display:none;
	z-index:5;
}
.layout-split-north{
	border-bottom:5px solid #efefef;
}
.layout-split-south{
	border-top:5px solid #efefef;
}
.layout-split-east{
	border-left:0px solid #efefef;
}
.layout-split-west{
	border-right:0px solid #efefef;
}
a:link {
 text-decoration: none;
}
a:visited {
 text-decoration: none;
}
a:hover {
 text-decoration: underline;
}
a:active {
 text-decoration: none;
}
.cs-north {
	height:40px;
	overflow:hidden;
}
.cs-north-bg {
	width: 100%;
	height: 100%;
	background: url(/resources/js/easyui/themes/bootstrap/images/header_bg.png) repeat-x;
}
.cs-north-logo {
	height: 30px;
	margin: 10px 0px 20px 5px;
	display: inline-block;
	color:#0E2D5F;
	font-size:20px;
	font-weight:bold;
	text-decoration:none;
}
.cs-north-info {
	position: absolute;
	color: #777;
	top: 10px;
	right: 30px;
	display: inline-block;
}
</style>
</head>
<body class="cmp-list-body">
	<!--<input type="hidden" name="marks" id="marks" value="${csrm.marks!}">-->
	<input type="hidden" name="repoId" id="repoId" value="${csrm.repoId!}">
	<div id="tb" style="padding:3px">
    	<span>关键字:</span>
		<input id="mark" class="easyui-textbox" style="width: 155px;" name="mark"/>
		
    	<a href="#" class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="doSearch();">查询</a> 
    	<a href="#" class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="submit();">提交</a> 
    	<a href="#" class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="del();">删除</a> 
	</div>
	
	<div id="mainPanle" region="center" border="false">
		<table id="tt" class="easyui-datagrid" title="APK列表" iconCls="icon-save" toolbar="#tb" rownumbers="true" idField="mark"
			url="/script/configList?isDelete=0&repoId=${csrm.repoId!}" checkOnSelect="false" selectOnCheck="false"
			pagination="true" fitColumns="true" pageSize="15" pageList="[15,30,60,80,100]"> 
		    <thead>		    
		    	<tr>
		    		<th align="center" width="5%" field="id" checkbox="true"></th>
		        	<th align="center" width="20%" field="mark">应用标识</th>
		            <th align="center" width="10%" field="apkName">apk名称</th>
		            <th align="center" width="5%" field="repoName">脚本库</th>
		        </tr>
		    </thead>   
		</table>
	</div>
	
<script>
function doSearch() {
	$('#tt').datagrid('load', {
		mark : $('#mark').val()
	});
}

$(document).ready(function(){
	$('#tt').datagrid({
		onSelect: function(index, row) {
			var repoName = row.repoName;
			if (repoName != '' && repoName != undefined && repoName != null) {
				alert("该记录已关联了脚本库！");
				$(this).datagrid('unselectRow', index);
			}
		}
	});
});

function del () {
	var rows = $('#tt').datagrid('getChecked');
	if (rows.length == 0) {
		showMsg(market.content.title, "请选择一条记录！", alert);
		return false;
	}
	console.info(rows.length);
	
	var marks = [];
	for (var i = 0; i < rows.length; i++) {
		marks.push(rows[i].mark);
	}
	console.info(marks);

	$.ajax({
		url : '/script/delMark',
		data : {
			marks : marks.join(",")
		},
		type : "POST",
		datatype : "json",
		async : true,
		success : function(data) {
			$('#tt').datagrid('reload');
		},
		error : function(data) {
			showMsg("温馨提示", data, alert);
		}
	});
}

function submit () {
	var rows = $('#tt').datagrid('getSelections');
	if (rows.length == 0) {
		showMsg(market.content.title, "请选择一条记录！", alert);
		return false;
	}
	console.info(rows.length);
	
	var marks = [];
	for (var i = 0; i < rows.length; i++) {
		marks.push(rows[i].mark);
	}
	
	$.ajax({
		url : '/script/addMark',
		data : {
			marks : marks.join(","),
			repoId : $('#repoId').val()
		},
		type : "POST",
		datatype : "json",
		async : true,
		success : function(data) {
			var code = data.return_code;
			parent.closeMyWindow();
			$('#tt').datagrid('reload');
		},
		error : function(data) {
			showMsg("温馨提示", data, alert);
		}
	});
}
</script>
</body>
</html>